<template>
  <view class="content">
    <view
      style="width: 100%; height: 80rpx; box-shadow: #d4d4d452 0px 0px 10px 5px"
    >
      <uni-segmented-control
        :current="nowPage"
        :values="['我报名的项目', '我竞价的项目', '我中标的项目']"
        styleType="text"
        activeColor="#136BFFFF"
        style="width: 100%;line-height: 80rpx;height: 80rpx;"
        @clickItem="onClickItem"
      ></uni-segmented-control>
    </view>
    <view style="width: 100%; height: calc(100vh - 80rpx)">
      <scroll-view
        style="height: calc(100vh - 80rpx)"
        scroll-y
        :scroll-top="scrollTop"
        @scrolltolower="bmLower"
        v-if="nowPage == 0 && baoming.length != 0"
      >
        <view class="project-list">
          <view
            class="project-info"
            v-for="(item, index) in baoming"
            :key="index"
          >
            <view style="width: 100%; display: flex">
              <view class="info-left">
                <image
                  :src="
                    item.imageUrl
                      ? baseUrl + item.imageUrl
                      : '../../static/image/1.jpg'
                  "
                />
              </view>
              <view class="info-right">
                <view
                  style="
                    white-space: nowrap;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    font-size: 14px;
                    font-weight: 600;
                  "
                  ><span style="color: #136bffff"
                    >[{{ item.resultName ? item.resultName : "暂无" }}]</span
                  >{{ item.projectName }}</view
                >
                <text class="project-detail"
                  >当前价格：{{
                    item.biddingPrice ? item.biddingPrice : 0
                  }}元</text
                >
                <view class="project-detail"
                  >项目类型：{{
                    item.dataTypeName ? item.dataTypeName : "暂无"
                  }}</view
                >
                <text class="project-detail"
                  >开始时间：{{
                    item.enrollStartTime ? item.enrollStartTime : "暂无"
                  }}</text
                >
                <text class="project-detail"
                  >结束时间：{{
                    item.enrollEndTime ? item.enrollEndTime : "暂无"
                  }}</text
                >
              </view>
            </view>
			<view style="width: 100%;height: 70rpx;display: flex;
					justify-content: center;
					align-items: center;">
					<view v-if="item.processStatus == 1">报名状态：待审核</view>
					<view v-if="item.processStatus == 2">报名状态：审核通过</view>
					<view v-if="item.processStatus == 3">报名状态：审核未通过</view>
				<view v-if="item.processStatus == 3"
				  style="
					padding: 0 10rpx; 
					height: 64rpx;
					background-color: #136bffff;
					color: white;
					text-align: center;
					line-height: 64rpx;
					border-radius: 10rpx;
					font-size: 13px;
					margin-left: 20rpx;
				  "
				  @click="goApplyInfo(item)"
				  >修改报名信息</view>
			  </view>
          </view>
        </view>
      </scroll-view>
      <view
        v-if="baoming.length == 0 && nowPage == 0"
        style="
          height: calc(100vh - 80rpx);
          width: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
          flex-direction: column;
        "
      >
        <image
          src="http://cdn.uviewui.com/uview/empty/list.png"
          style="width: 360rpx; height: 360rpx"
        ></image>
        <p style="color: rgb(192, 196, 204)">列表为空</p>
      </view>
      <view
        v-if="jingjia.length == 0 && nowPage == 1"
        style="
          height: calc(100vh - 80rpx);
          width: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
          flex-direction: column;
        "
      >
        <image
          src="http://cdn.uviewui.com/uview/empty/list.png"
          style="width: 360rpx; height: 360rpx"
        ></image>
        <p style="color: rgb(192, 196, 204)">列表为空</p>
      </view>
      <view
        v-if="zhongbiao.length == 0 && nowPage == 2"
        style="
          height: calc(100vh - 80rpx);
          width: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
          flex-direction: column;
        "
      >
        <image
          src="http://cdn.uviewui.com/uview/empty/list.png"
          style="width: 360rpx; height: 360rpx"
        ></image>
        <p style="color: rgb(192, 196, 204)">列表为空</p>
      </view>
      <scroll-view
        style="height: calc(100vh - 80rpx)"
        scroll-y
        @scrolltolower="jjLower"
        :scroll-top="scrollTop"
        v-if="nowPage == 1 && jingjia.length != 0"
      >
        <view class="project-list">
          <view
            class="project-info"
            v-for="(item, index) in jingjia"
            :key="index"
          >
            <view style="width: 100%; display: flex">
              <view class="info-left">
                <image
                  :src="
                    item.imageUrl
                      ? baseUrl + item.imageUrl
                      : '../../static/image/1.jpg'
                  "
                />
              </view>
              <view class="info-right">
                <view
                  style="
                    white-space: nowrap;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    font-size: 14px;
                    font-weight: 600;
                  "
                  ><span style="color: #136bffff"
                    >[{{ item.resultName ? item.resultName : "暂无" }}]</span
                  >{{ item.projectName }}</view
                >
                <text class="project-detail"
                  >当前价格：{{
                    item.biddingPrice ? item.biddingPrice : 0
                  }}元</text
                >
                <text class="project-detail"
                  >项目类型：{{
                    item.transferMethodName ? item.transferMethodName : "暂无"
                  }}</text
                >

                <text class="project-detail"
                  >开始时间：{{
                    item.enrollStartTime ? item.enrollStartTime : "暂无"
                  }}</text
                >
                <text class="project-detail"
                  >结束时间：{{
                    item.enrollEndTime ? item.enrollEndTime : "暂无"
                  }}</text
                >
                <view
                  style="
                    width: 154rpx;
                    height: 64rpx;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    background-color: #136bffff;
                    color: white;
                    border-radius: 10rpx;
                    font-size: 13px;
                    margin-top: 6rpx;
                  "
                  @click="jingjia1(item)"
                  >立即竞价</view
                >
              </view>
            </view>
          </view>
        </view>
      </scroll-view>
      <scroll-view
        style="height: calc(100vh - 80rpx)"
        scroll-y
        @scrolltolower="zbLower"
        :scroll-top="scrollTop"
        v-if="nowPage == 2 && zhongbiao.length != 0"
      >
        <view class="project-list">
          <view
            class="project-info"
            v-for="(item, index) in zhongbiao"
            :key="index"
            @click="goProjectInfo(item)"
          >
            <view style="width: 100%; display: flex">
              <view class="info-left">
                <image
                  :src="
                    item.imageUrl
                      ? baseUrl + item.imageUrl
                      : '../../static/image/1.jpg'
                  "
                />
              </view>
              <view class="info-right">
                <view
                  style="
                    white-space: nowrap;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    font-size: 14px;
                    font-weight: 600;
                  "
                  ><span style="color: #136bffff"
                    >[{{ item.resultName ? item.resultName : "暂无" }}]</span
                  >{{ item.projectName }}</view
                >
                <text class="project-detail"
                  >成交价格：{{ item.biddingPrice }}元</text
                >
                <text class="project-detail"
                  >项目类型：{{
                    item.transferMethodName ? item.transferMethodName : "暂无"
                  }}</text
                >
                <text class="project-detail"
                  >交易结果：{{
                    item.resultName ? item.resultName : "暂无"
                  }}</text
                ><text class="project-detail"
                  >开始时间：{{ item.biddingStartTime }}</text
                >
                <text class="project-detail"
                  >结束时间：{{ item.biddingEndTime }}</text
                >
              </view>
            </view>
            <view
              v-if="item.doneStatus == 2"
              style="
                width: 154rpx;
                height: 64rpx;
                display: flex;
                justify-content: center;
                align-items: center;
                background-color: #136bffff;
                color: white;
                border-radius: 10rpx;
                font-size: 13px;
                margin-left: 230rpx;
                margin-top: 6rpx;
              "
              @click.stop="gongshi(item)"
              >成交公示</view
            >
          </view>
        </view>
      </scroll-view>
    </view>
  </view>
</template>

<script>
import { mineProject } from "@/utils/api.js";
export default {
  data() {
    return {
      nowPage: 0,
      baoming: [],
      jingjia: [],
      zhongbiao: [],
      baseUrl: this.$baseUrl,
      nowPageNum: 1,
      scrollTop: 0,
    };
  },
  onLoad(e) {
    this.nowPage = parseInt(e.page);
  },
  onShow() {
    // 报名项目列表
    this.getGrEnrollSupplyProject();
    // 竞价项目列表
    this.getGrBiddingSupplyProject();
    // 中标项目列表
    this.getGrWinSupplyProject();
  },
  methods: {
    bmLower() {
      this.nowPageNum++;
      this.getGrEnrollSupplyProject(true);
    },
    jjLower() {
      this.nowPageNum++;
      this.getGrBiddingSupplyProject(true);
    },
    zbLower() {
      this.nowPageNum++;
      this.getGrWinSupplyProject(true);
    },
    // 报名项目
    async getGrEnrollSupplyProject(e) {
      let res = await mineProject.getGrEnrollSupplyProject({
        pageNum: this.nowPageNum,
        pageSize: 10,
      });
      console.log("报名项目", res);
      if (e) {
        this.baoming = [...this.baoming, ...res.data.rows];
      } else {
        this.baoming = res.data.rows;
      }
    },
	//////获取审核驳回 理由
	 getPersonalApplyInfo(e) {
	 let paras = {
			 dataId: e.dataId,
			 dataType: e.dataType
		 };
	   electBidding.getPersonalApplyInfo(paras).then(res => {
			if (res.code == 1000) {
			console.log(res);
			this.ieda = res.data.main.idea;
			} else {
				this.$message.error(res.message);
			}
		}).catch((err) => {
			console.log('err', err);
		});;
	},
    // 竞价项目
    async getGrBiddingSupplyProject(e) {
      let res = await mineProject.getGrBiddingSupplyProject({
        pageNum: this.nowPageNum,
        pageSize: 10,
      });
      console.log("竞价项目", res);
      if (e) {
        this.jingjia = [...this.jingjia, ...res.data.rows];
      } else {
        this.jingjia = res.data.rows;
      }
    },
    // 中标项目
    async getGrWinSupplyProject(e) {
      let res = await mineProject.getGrWinSupplyProject({
        pageNum: this.nowPageNum,
        pageSize: 10,
      });
      console.log("中标项目", res);
      if (e) {
        this.zhongbiao = [...this.zhongbiao, ...res.data.rows];
      } else {
        this.zhongbiao = res.data.rows;
      }
    },
    goSignUp(e) {
      uni.navigateTo({
        url: "/pages/electBidding/signUp?data=" + e,
      });
    },
    onClickItem(e) {
      this.nowPage = e.currentIndex;
      // 初始页面设为0
      this.nowPageNum = 1;
      // scroll滚回最上方
      this.scrollTop = -1;
      this.$nextTick(function () {
        this.scrollTop = 0;
      });
      if (e.currentIndex == 0) {
        this.getGrEnrollSupplyProject(false);
      }
      if (e.currentIndex == 1) {
        this.getGrBiddingSupplyProject(false);
      }
      if (e.currentIndex == 2) {
        this.getGrWinSupplyProject(false);
      }
    },
    goApplyInfo(e) {
      console.log(e);
      uni.navigateTo({
        url:
          "/pages/electBidding/signUp?dis=1&data=" +
          JSON.stringify({ dataId: e.dataId, dataType: e.dataType,})+"&Id="+e.id,
      });
    },
    gongshi(e) {
      console.log(e);
      uni.navigateTo({
        url:
          "/pages/dealPublicity/dealPublicity?data=" +
          JSON.stringify(e) +
          "&jieshu=1",
      });
    },
    jingjia1(e) {
      uni.navigateTo({
        url: "/pages/electBidding/bidding?data=" + JSON.stringify(e),
      });
    },
    goProjectInfo(e) {
      uni.navigateTo({
        url:
          "/pages/supplyDetails/supplyDetails?data=" +
          JSON.stringify({
            projectId: e.id,
            dataId: e.dataId,
            dataType: e.dataType,
          }),
      });
    },
  },
};
</script>

<style scoped lang="less">
.content {
  width: 100%;
  display: flex;
  height: 100vh;
  flex-direction: column;
  align-items: center;
}
.project-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  .project-info {
    width: 92%;
    margin-top: 20rpx;
    margin-bottom: 20rpx;
    display: flex;
    flex-direction: column;
    padding-bottom: 28rpx;
    border-bottom: 1px solid #f3f3f3ff;
    .info-left {
      image {
        width: 220rpx;
        height: 300rpx;
        border-radius: 10rpx;
      }
    }
    .info-right {
      width: 470rpx;
      margin-left: 14rpx;
      display: flex;
      justify-content: space-around;
      flex-direction: column;
      .project-detail {
        font-size: 13px;
        color: #828282ff;
      }
    }
  }
}
</style>
